package com.shushan.setting.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ChildInfoBean
 * @Desciption: 家长设置首页
 * @author: yichaohua
 * @date: 2018-08-13
 */
public class ChildInfoBean extends NetBaseBean {

    public int id;
    public String child_name;
    public int grade_id;
    public String grade_name;
    public String semester;
    public int sex;

    private List<BookBean> bookBeanList = new ArrayList<BookBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        JSONObject infoJson = jsonObject.optJSONObject("child_info");
        if(infoJson != null){
            id = infoJson.optInt("id",0);
            child_name = infoJson.optString("child_name","");
            grade_id = infoJson.optInt("grade_id",0);
            grade_name = infoJson.optString("grade_name","");
            semester = infoJson.optString("semester","");
            sex = infoJson.optInt("sex",1);
        }

        JSONArray jsonArray = jsonObject.optJSONArray("outline_info");
        if(jsonArray != null){
            for (int i = 0;i < jsonArray.length();i++){
                JSONObject object = jsonArray.optJSONObject(i);
                BookBean bookBean = new BookBean();
                bookBean.initByJson(object);
                bookBeanList.add(bookBean);
            }
        }
    }

    public List<BookBean> getBookBeanList() {
        return bookBeanList;
    }

    public void setBookBeanList(List<BookBean> bookBeanList) {
        this.bookBeanList = bookBeanList;
    }
}
